def a(num):
    if num < 2:
        return False
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            return False
    return True

def m(num):
    while True:
        if a(num):
            return num
        num += 1

def w(o):
    numbers = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}
    return numbers.get(o, None)

def main():
    s = input().split()
    if len(s) != 3:
        print("Wrong input")
        return

    num = 0
    for o in s:
        number = w(o)
        if number is None:
            print("Wrong input")
            return
        num = num*10 + number

    if 100 <= num <= 999:
        res = m(num)
        print(res)
    else:
        print("Wrong input")

if __name__ == "__main__":
    main()
